﻿/************************************************************************************
 *      Copyright (C) 2015 yuwei,All Rights Reserved
 *      File:
 *				PersonService.cs
 *      Description:
 *		    空对象模式项目,用户信息数据库访问类
 *      Author:
 *				yangxianwen
 *				
 *				
 *      Finish DateTime:
 *				2017年07月20日
 *      History:
 ***********************************************************************************/


namespace NullObjectPattern
{
    public class PersonService
    {
        /// <summary>
        /// 获取用户信息方法
        /// </summary>
        /// <param name="id">用户id</param>
        /// <returns>用户信息对象实体</returns>
        public Human GetPersonById(int id)
        {
            Human human = null;
            if (id == 1)
            {
                human = new Person
                {
                    Id = 111,
                    Name = "小明"
                };
            }
            else
            {
                human = new NullPerson
                {
                    Id = 0,
                    Name = "未知"
                };
            }
            return human;
        }

    }
}
